package com.kaibes.module.shelter;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ShelterUtils {

    @Autowired
    private ShelterService shelterService;
    
    public String filter(String tag, String content) {
        List<Shelter> shelters = shelterService.listByTag(tag);
        for (Shelter shelter : shelters) {
            content = content.replaceAll(shelter.getSource(), shelter.getTarget());
        }
        return content;
    }
    
}
